import {createRouter, createWebHistory, RouteRecordRaw} from 'vue-router'
import interceptor from './interceptor'


const routes: RouteRecordRaw[] = [
    {
        path: '/:pathMatch(.*)',
        redirect: '/404'
    },
    {
        path: "/",
        redirect: '/homePage'
    },
    {
        path: "/home",
        component: () => import('@/views/Layout/index.vue'),
        children: [
            {
                path: "/homePage",
                meta: {title: 'Vant4-VUE3',},
                component: () => import('@/views/HomePage/index.vue')
            },
            {
                path: "/mine",
                meta: {title: 'Vant4-VUE3',},
                component: () => import('@/views/Mine/index.vue')
            },
            {
                path: "/news",
                meta: {title: 'Vant4-VUE3',},
                component: () => import('@/views/News/index.vue')
            },
        ]
    },
    {
        path: "/test",
        component: () => import('@/views/Test/index.vue')
    },
    {
        path: "/login",
        component: () => import('@/views/Login/index.vue')
    },
    {
        path: "/404",
        meta: {title: '页面不存在',},
        component: () => import('@/components/NotFound.vue')
    },

]

const router = createRouter({
    routes,
    history: createWebHistory(),
})

interceptor(router)
export default router
